﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Golf.WebUI.AdminShow.CouponsManagement
{
    public partial class RebateLogAdd : Golf.WebUI.App_code.ValidateLogin
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "用户会员id	Golf_Use格式错误！\\n";
            }
            if (this.txtCouponsNumber.Text.Trim().Length == 0)
            {
                strErr += "优惠券编号不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtCouponsUseType.Text))
            {
                strErr += "使用类型	1创建格式错误！\\n";
            }
            if (!PageValidate.IsNumber(txtAdminid.Text))
            {
                strErr += "创建管理人id	Golf_Ad格式错误！\\n";
            }
            if (this.txtAdminname.Text.Trim().Length == 0)
            {
                strErr += "创建管理人名称	Golf_Ad不能为空！\\n";
            }
            if (!PageValidate.IsDateTime(txtCreatetime.Text))
            {
                strErr += "创建时间格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int UserId = int.Parse(this.txtUserId.Text);
            string CouponsNumber = this.txtCouponsNumber.Text;
            int CouponsUseType = int.Parse(this.txtCouponsUseType.Text);
            int Adminid = int.Parse(this.txtAdminid.Text);
            string Adminname = this.txtAdminname.Text;
            DateTime Createtime = DateTime.Parse(this.txtCreatetime.Text);

            Golf.Model.Golf_CouponsLog model = new Golf.Model.Golf_CouponsLog();
            model.UserId = UserId;
            model.CouponsNumber = CouponsNumber;
            model.CouponsUseType = CouponsUseType;
            model.Adminid = Adminid;
            model.Adminname = Adminname;
            model.Createtime = Createtime;

            Golf.BLL.Golf_CouponsLog bll = new Golf.BLL.Golf_CouponsLog();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

        }

        protected void btnCancle_Click(object sender, EventArgs e)
        {

        }
    }
}